package com.intranet.fund.dao;

import java.util.List;

import org.springframework.stereotype.Repository;

import com.intranet.fund.domain.Blacklist;
import com.water.dao.BaseDao;
import com.water.dao.Page;

@Repository
public class BlacklistDao extends BaseDao<Blacklist> {

	private final String GET_BLACKLIST_BY_IP = "from Blacklist b where b.ip = ?";

	public Page queryBlacklistList(int pageNo, int pageSize, String param) {
		StringBuffer sb = new StringBuffer();
		sb.append("from Blacklist where 1=1");
		sb.append(" order by id");
		return pagedQuery(sb.toString(), pageNo, pageSize);
	}

	public Blacklist getBlacklistByIp(String ip) {
		List<Blacklist> blacklists = (List<Blacklist>) getHibernateTemplate()
				.find(GET_BLACKLIST_BY_IP, ip);
		if (blacklists.size() == 0) {
			return null;
		} else {
			return blacklists.get(0);
		}
	}

}
